#pragma once
#include <vector>
#include "Element.h"
#include "IUIDialog.h"
namespace UILib
{
#ifndef UI_DIALOG
    typedef CWinTraits<WS_CLIPCHILDREN | WS_CLIPSIBLINGS\
        , 0L > CDialogTraits;
#endif

    const wchar_t wszUIWndName[] = L"UILib_Dialog";

    class CDrawDialog : public CWindowImpl<CDrawDialog, CWindow, CDialogTraits>\
        , IUIDialog
    {
    public:
        CDrawDialog(const UINT uID = -1);
        virtual ~CDrawDialog(void);

        DECLARE_WND_CLASS(wszUIWndName)
        virtual BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0);

    public:
        virtual void InitParam(const PDialogParam pParam);

        virtual void Show( const UINT uWSP, const bool bCenter = false );

        virtual HWND Get_HWnd() const{ return m_hWnd; };

        virtual void Set_DialogEvent( const PDialogEvent pEvent );

        virtual void Set_CustomObserver(const PCustomObserver pObserver );

        virtual void Add_MessageFilter( const PUIMessageFilter pFilter );

        virtual void Set_ID( const UINT uID );
        virtual UINT Get_ID() const { return uID_; };

        virtual void Set_BackgroundColor( const COLORREF cl );
    protected:
        virtual LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnNcDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnLbuttonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnLbuttonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

        virtual void Render(const PAINTSTRUCT &ps);

        CElement* GetElement(const UINT uID);
    protected:
        UINT                uID_;
        vector<CElement*>   vecElem_;
        PDialogEvent        DialogEvent_;
        PCustomObserver     CustomObserver_;
        PUIMessageFilter    MsgFilter_;

        HWND                hOwner_;
        bool                bInit_;
        bool                bChild_;
        bool                bTracking_;
        RECT                rcCaption_;

        COLORREF            clBackGround_;
    };
}
